import xml.etree.ElementTree as ET
from enum import Enum


class VehicleType(Enum):
    a = "行李牵引车"


def build_xml():
    """
    构建指定结构的XML内容并返回XML字符串
    """
    xml_declaration = '<?xml version="1.0" encoding="UTF-8"?>'
    # 创建根元素MSG
    root = ET.Element("MSG")

    # 创建META子元素及其内容
    meta = ET.SubElement(root, "META")
    sndr = ET.SubElement(meta, "SNDR")
    sndr.text = "GPS Information"
    rcvr = ET.SubElement(meta, "RCVR")
    seqn = ET.SubElement(meta, "SEQN")
    seqn.text = "0"
    ddtm = ET.SubElement(meta, "DDTM")
    ddtm.text = "20240530155904"
    type_elem = ET.SubElement(meta, "TYPE")
    type_elem.text = "GISDATA"
    styp = ET.SubElement(meta, "STYP")
    styp.text = "VehicleAdd"
    sorc = ET.SubElement(meta, "SORC")
    sorc.text = "GIS"
    mgid = ET.SubElement(meta, "MGID")
    mgid.text = "12bf79449e474dcdac9a6e1abf526bad"
    rmid = ET.SubElement(meta, "RMID")
    rmid.text = "A2012122-0234-816R-E7A9-7855BA84fd5B"
    apot = ET.SubElement(meta, "APOT")
    apot.text = "ZUCK"

    # 创建DFLT子元素及其内容
    dflt = ET.SubElement(root, "DFLT")
    operation = ET.SubElement(dflt, "operation")
    operation.text = "1"
    createTime = ET.SubElement(dflt, "createTime")
    createTime.text = "2024-04-12 15:33:46"
    updateTime = ET.SubElement(dflt, "updateTime")
    updateTime.text = "2024-04-12 15:33:46"
    licenseNum = ET.SubElement(dflt, "licenseNum")
    licenseNum.text = "民航-D1950"
    appUnitName = ET.SubElement(dflt, "appUnitName")
    manageUnitName = ET.SubElement(dflt, "manageUnitName")
    manageUnitName.text = "1778684765700431873"
    contactPerson = ET.SubElement(dflt, "contactPerson")
    contactPerson.text = "123"
    telephone = ET.SubElement(dflt, "telephone")
    telephone.text = "13566666666"
    brand = ET.SubElement(dflt, "brand")
    model = ET.SubElement(dflt, "model")
    engineNumber = ET.SubElement(dflt, "engineNumber")
    producePlace = ET.SubElement(dflt, "producePlace")
    fuelName = ET.SubElement(dflt, "fuelName")
    fuelName.text = "oil"
    vehicleLoad = ET.SubElement(dflt, "vehicleLoad")
    vehicleColor = ET.SubElement(dflt, "vehicleColor")
    vehicleStateName = ET.SubElement(dflt, "vehicleStateName")
    vehicleStateName.text = "normal"
    produceDate = ET.SubElement(dflt, "produceDate")
    firstRegistDate = ET.SubElement(dflt, "firstRegistDate")
    licenceDate = ET.SubElement(dflt, "licenceDate")
    serviceLife = ET.SubElement(dflt, "serviceLife")
    serviceLife.text = "-1"
    scrapDate = ET.SubElement(dflt, "scrapDate")
    vehicleType = ET.SubElement(dflt, "vehicleType")
    vehicleType.text = "行李牵引车"
    vehicleUse = ET.SubElement(dflt, "vehicleUse")
    accessPrivilege = ET.SubElement(dflt, "accessPrivilege")
    vehicleHeight = ET.SubElement(dflt, "vehicleHeight")
    vehicleLong = ET.SubElement(dflt, "vehicleLong")
    vehicleWide = ET.SubElement(dflt, "vehicleWide")
    socialLicence = ET.SubElement(dflt, "socialLicence")
    propertyRight = ET.SubElement(dflt, "propertyRight")
    annualInfo = ET.SubElement(dflt, "annualInfo")
    reviewInfo = ET.SubElement(dflt, "reviewInfo")
    concreteWork = ET.SubElement(dflt, "concreteWork")
    remarks = ET.SubElement(dflt, "remarks")
    lastYearKm = ET.SubElement(dflt, "lastYearKm")
    lastYearKm.text = "-1"
    thisYearKm = ET.SubElement(dflt, "thisYearKm")
    thisYearKm.text = "-1"
    changeKm = ET.SubElement(dflt, "changeKm")
    changeKm.text = "-1"
    thisYearRoadhaul = ET.SubElement(dflt, "thisYearRoadhaul")
    thisYearRoadhaul.text = "-1"
    accumulateRoadhaul = ET.SubElement(dflt, "accumulateRoadhaul")
    accumulateRoadhaul.text = "-1"
    simCode = ET.SubElement(dflt, "simCode")
    simCode.text = "13900005047"
    ip = ET.SubElement(dflt, "ip")
    sysinfoName = ET.SubElement(dflt, "sysinfoName")
    feedbackFrequency = ET.SubElement(dflt, "feedbackFrequency")
    feedbackFrequency.text = "-1"
    macId = ET.SubElement(dflt, "macId")
    macId.text = "13900005047"
    vendor = ET.SubElement(dflt, "vendor")
    vin = ET.SubElement(dflt, "vin")

    xml_str = ET.tostring(root, encoding='utf-8', method='xml').decode('utf-8')
    full_xml_str = xml_declaration + "\n" + xml_str
    # 将构建好的XML结构转换为字符串并返回，设置缩进等格式化选项
    return full_xml_str


if __name__ == '__main__':
    print(build_xml())
